//保存
function getData() {
    var xmlhttp;
    
    var issu = document.getElementById("inissue").value;
    var st = document.getElementById("indata").value;
    var partn=/^[0-9]*$/;
    if (issu.replace(/\s+/g,"").length==0) {
      alert("请输入几期");
      return;
    }
    if (!partn.test(issu)) {
      alert("请输入数字");
      return;
    }
    if (st.replace(/\s+/g,"").length==0) {
      alert("请输入开出数");
      return;
    }
    if (!partn.test(st)) {
      alert("请输入数字");
      return;
    }
    
    document.getElementById("showissue").innerHTML="正在返回数据，请等待......";
    //st = st.replace(/\s+/g, "");
    issu=encodeURI(issu);
    st = encodeURI(st);
    if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp = new XMLHttpRequest();
    } else { // code for IE6, IE5
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        
        document.getElementById("showissue").innerHTML = xmlhttp.responseText;
      }
    }
    var url = "";
    url = "save.php";
    url = url + "?val=" + st+"&iss="+issu;
    url = url + "&sid=" + Math.random();
    xmlhttp.open("GET", url, false);
    xmlhttp.send();
    document.getElementById("inissue").value="";
    document.getElementById("indata").value="";
    freshData();
  }
//刷新
function freshData() {
    var xmlhttp; 
    document.getElementById("list").innerHTML="正在返回数据，请等待......";
    if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp = new XMLHttpRequest();
    } else { // code for IE6, IE5
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        
        document.getElementById("list").innerHTML = xmlhttp.responseText;
      }
    }
    var url = "";
    url = "freshdata.php";
    url = url ;
    url = url + "?sid=" + Math.random();
    xmlhttp.open("GET", url, true);
    xmlhttp.send();
   
  }
  function freshData1() {
    var xmlhttp;
    document.getElementById("showissue").innerHTML = "正在返回数据，请等待......";
    if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp = new XMLHttpRequest();
    } else { // code for IE6, IE5
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function () {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  
        document.getElementById("showissue").innerHTML = xmlhttp.responseText;
      }
    }
    var url = "";
    url = "freshdata1.php";
    url = url;
    url = url + "?sid=" + Math.random();
    xmlhttp.open("GET", url, true);
    xmlhttp.send();
  }
  
  //删除最新
  function delData() {
    if(confirm("确定删除？")){
    var xmlhttp; 
    document.getElementById("backdel").innerHTML="正在删除，请等待......";
    if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp = new XMLHttpRequest();
    } else { // code for IE6, IE5
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        
        document.getElementById("backdel").innerHTML = xmlhttp.responseText;
      }
    }
    var url = "";
    url = "delnew.php";
    url = url ;
    url = url + "?sid=" + Math.random();
    xmlhttp.open("GET", url, false);
    xmlhttp.send();
    freshData() ;
    freshData1() ;
  }
  }
  //显示隐藏列表
  function showhidd(){
    var sList = document.getElementById("display");
    if (sList.style.display == "none") {
      sList.style.display = "block";
    } else {
      sList.style.display = "none";
    }
    freshData();
  }